import {defineStore} from "pinia";

export const useUserStore = defineStore('userStore', {
        state: () => ({
            user:  '',
            token: ''
        }),
        getters: {
            getUsername(state) {
                if (state.user) {
                    return JSON.parse(state.user).username
                }
            },
            getUserId(state) {
                if (state.user) {
                    return JSON.parse(state.user).userId
                }
            },
            getAvatar(state) {
                if (state.user) {
                    return JSON.parse(state.user).avatarUrl
                }
            },
            getPhone(state) {
                if (state.user) {
                    return JSON.parse(state.user).phone
                }
            },
            getActivePlus(state) {
                if (state.user){
                    return JSON.parse(state.user).activePlus
                }
            },
            getEmail(state) {
                if (state.user) {
                    return JSON.parse(state.user).email
                }
            },
            getGender(state) {
                if (state.user) {
                    return JSON.parse(state.user).gender
                }
            }
        }
    }
);

